Close Encounters of the Higher Kind Emulating Constructor Classes in Standard ML

نویسندگان

  • Yutaka Nagashima
  • Liam O'Connor
چکیده

In our recent work [5] on automating Isabelle proofs, we discovered that several proof search problems can be elegantly expressed as a monadic program. Unfortunately, Standard ML does not natively support the kinds of polymorphism required to easily express a Monad abstraction, nor similar abstractions such as Applicative and Functor . In this paper, we present a technique for encoding constructor classes such as Monad, which relies only on the Standard ML module system. Several others have attempted to enable constructor classes in Standard ML by changing the language. While it is tempting to customise the language by adding new features, new features tend to cause duplication [2] and inconsistency [3]. Furthermore, avoiding language extensions makes our approach transferable to all other ML dialects with a module system. Our contributions are twofold: we develop a usable library for monads, monad transformers, applicatives, and more in Standard ML, and demonstrate an elegant technique using ML functors to elaborate minimal definitions of each abstraction to avoid code duplication. For example, given a minimal definition of the list monad, e.g. return and bind, our library derives other basic functions, such as >=>, join, and liftM automatically. Moreover, using the hierarchical relationship among constructor classes, our library automatically instantiates list as a member of the parent classes, e.g. applicative and functor. Thus, for each monad, users can derive more than twenty functions from two manually written functions, i.e. return and bind.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Continuation semantics and self-adjointness

We give an abstract categorical presentation of continuation semantics by taking the continuation type constructor : (or cont in Standard ML of New Jersey) as primitive. This constructor on types extends to a contravariant functor on terms which is adjoint to itself on the left; restricted to the subcategory of those programs that do not manipulate the current continuation, it is adjoint to its...

متن کامل

Lightweight Higher-Kinded Polymorphism

Higher-kinded polymorphism —i.e. abstraction over type constructors— is an essential component of many functional programming techniques such as monads, folds, and embedded DSLs. ML-family languages typically support a form of abstraction over type constructors using functors, but the separation between the core language and the module language leads to awkwardness as functors proliferate. We s...

متن کامل

No-Longer-Foreign: Teaching an ML compiler to speak C "natively"

We present a new foreign-function interface for SML/NJ. It is based on the idea of datalevel interoperability—the ability of ML programs to inspect as well as manipulate C data structures directly. The core component of this work is an encoding of the almost 2 complete C type system in ML types. The encoding makes extensive use of a “folklore” typing trick, taking advantage of ML’s polymorphism...

متن کامل

Isabelle/HOL-NSA — Non-Standard Analysis

3 Construction of Star Types Using Ultrafilters 14 3.1 A Free Ultrafilter over the Naturals . . . . . . . . . . . . . . . 15 3.2 Definition of star type constructor . . . . . . . . . . . . . . . 15 3.3 Transfer principle . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.4 Standard elements . . . . . . . . . . . . . . . . . . . . . . . . 17 3.5 Internal functions . . . . . . . . . . . . . ....

متن کامل

Higher order close-to-convex functions associated with Attiya-Srivastava operator

In this paper‎, ‎we introduce a new class$T_{k}^{s,a}[A,B,alpha‎ ,‎beta ]$ of analytic functions by using a‎ ‎newly defined convolution operator‎. ‎This class contains many known classes of‎ ‎analytic and univalent functions as special cases‎. ‎We derived some‎ ‎interesting results including inclusion relationships‎, ‎a radius problem and‎ ‎sharp coefficient bound for this class‎.

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:
  • CoRR

دوره abs/1608.03350  شماره 

صفحات  -

تاریخ انتشار 2016